let url = "http://localhost:8000";

//返回所有数据
function getproduceList() {
    return new Promise((resolve, reject) => {
        $.get(`${url}/produce`, (data) => {
            resolve(data);
        })
    })
}

//关键字查找产品
function queryproductbykeyword(keyword) {
    return new Promise((resolve, reject) => {
        $.get(`${url}/produce?keyword=${keyword}`, (data) => {
            resolve(data);
        })
    })
}

//根据id删除指定产品
function delproductById(id) {
    return new Promise((resolve, reject) => {
        $.ajax({
            url: `${url}/produce/${id}`,
            type: "delete",
            success: (data) => {
                resolve(data)
            }
        })
    })
}

//根据id去编辑指定产品
function enditproductById(id) {
    return new Promise((resolve, reject) => {
        $.get(`${url}/produce/${id}`, (data) => {
            resolve(data);
        })
    })
}

//新增产品
function addproduct(obj) {
    return new Promise((resolve, reject) => {
        $.post(`${url}/produce`, obj, () => {
            resolve();
        })
    })
}

//修改产品信息
function updateproduct(obj) {
    return new Promise((resolve, reject) => {
        $.ajax({ //修改
            url: `${url}/produce`,
            method: "put",
            data: obj,
            success: () => {
                resolve();
            }
        })
    })
}